package cn.lbf.stuniversity.equipmentbasic.controller;

import cn.lbf.stuniversity.equipmentbasic.entity.EquipmentBasic;
import cn.lbf.stuniversity.equipmentbasic.service.EquipmentBasicService;
import cn.lbf.stuniversity.vo.Result;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import cn.lbf.stuniversity.equipmentbasic.form.*;
import org.springframework.data.domain.Page;
@RequestMapping("/equipBasic")
@RestController
@CrossOrigin
public class EquipmentBasicController {
    @Autowired
    private EquipmentBasicService equipmentBasicService;

    // 查询所有设备基础信息
    @RequestMapping("/selectAll")
    public List<EquipmentBasic> selectAll() {
        return equipmentBasicService.selectAll();
    }

    // 添加新的设备基础信息
    @PostMapping("/addNew")
    public Result<Map<String, Object>> addNew(@Valid @RequestBody EquipmentBasicAddForm form) {
        System.out.println(form);
        return equipmentBasicService.addNew(form);
    }

    // 分页查询设备基础信息
    @GetMapping("/queryList")
    public Result<Page<EquipmentBasic>> queryList(@Valid EquipmentBasicForm form) {
        return equipmentBasicService.queryList(form);
    }

    // 删除设备基础信息
    @GetMapping("/del")
    public Result<String> del(String equipmentBasicId) {
        return equipmentBasicService.del(equipmentBasicId);
    }

    // 更新设备基础信息
    @PostMapping("/edit")
    public Result<String> edit(@Valid @RequestBody EquipmentBasicDetailForm form) {
        return equipmentBasicService.updateByEquipmentBasicId(form);
    }
}
